Login page perl/CGI
am 27.04.2007 07:53:03 von Sandyhello,,,,,,,,,
i am creating login page using Perl/CGI facing prob... able to
connect DB but from there facing prob
If u have related code of login page in Perl please send me on
sandip.bhosale@gmail.com
please help me
i am using MySQL as DB user name:root password:root database name:ITS
and Table is User_login,
Column 1: User_Name
Column 2: User_Pass
--
#!c:/perl/bin/perl.exe
use CGI qw(:standard);
use CGI::Carp qw(warning's fatalsToBrowser);
use strict;
use DBI;
print "Content-type: text/html\n\n";
print <
BodyHTML
print end_html;
my $dbh = DBI->connect("DBI:mysql:database:localhost","its","root",
{ RaiseError => 1,
AutoCommit => 1 }) or &dienice("Can't connect to database:
$DBI::errstr");
my $UserName=param('UserName');
my $Password=param('Password');
my $sth = $dbh->prepare("select * from User_Login where User_Name
= ?") or &dbdie;
$sth->execute($UserName) or &dbdie;
if (my $name = $sth->fetchrow_hashref)
{
my $sth = $dbh->prepare("select * from user_Login where root = ?") or
&dbdie;
$sth->execute($Password) or &dbdie;
if (my $pass = $sth->fetchrow_hashref)
{
print redirect(- location=>"index.cgi");
}
else { &dienice(qq(The password is invalid. Go to the "passreset.cgi">password reset page to reset your password.)); }
}
else { &dienice(qq(Username does not exist. Go to the registration page to register.)); }
$dbh->disconnect;
print end_html;
sub dienice {
my ($msg) = @_;
print "
$msg
";exit;
}
sub dbdie {
my ($errmsg) = "$DBI::errstr
";
&dienice($errmsg);
}
Sandip B Bhosale.